#include "gwlib/gwlib.h"

#include "gwbase/curl_wrapper.h"
#include "gwbase/base/logging.h"

namespace dicom {

void InitGwLib() {
  // add initialization code here
}

class ExternalLogSink: public dicom::LogSink {
 public:
  ExternalLogSink(log_callback cb): cb_(cb) { }
  virtual ~ExternalLogSink() { }

  virtual void WriteLog(const void* buf, size_t len) { 
    std::string str;
    str.append(static_cast<const char*>(buf), len);
    cb_(str.c_str());
  }

  virtual void Flush() { }
 private:
  log_callback cb_;
};

void SetGwLogcallback(log_callback cb) {
  dicom::SetLogSink(new ExternalLogSink(cb));
}

}

